---
global:
  scrape_interval: 15s
  evaluation_interval: 15s
  scrape_timeout: 10s
  external_labels:
    monitor: 'Alertmanager'

rule_files:
  - 'alert.rules'

scrape_configs:
{% if prometheus_monitor_prometheus %}
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']
{% endif %}

  - job_name: 'speedtest'
    metrics_path: /metrics
    scrape_interval: {{ monitoring_speedtest_interval }}
    scrape_timeout: 60s  # running speedtest needs time to complete
    static_configs:
      - targets: ['speedtest:9798']

{% if shelly_plug_enable %}
  - job_name: 'shelly-plug'
    metrics_path: /metrics
    scrape_interval: 1m
    static_configs:
      - targets: ['172.17.0.1:9924']
{% endif %}

{% if airgradient_enable %}
{% for sensor in airgradient_sensors %}
  - job_name: 'airgradient-{{ sensor.id }}'
    metrics_path: /metrics
    scrape_interval: 30s
    static_configs:
      - targets: ['{{ sensor.ip }}:{{ sensor.port }}']
{% endfor %}
{% endif %}

{% if starlink_enable %}
  - job_name: 'starlink'
    metrics_path: /metrics
    static_configs:
      - targets: ['172.17.0.1:9817']
{% endif %}

  - job_name: 'ping'
    metrics_path: /probe
    scrape_interval: {{ monitoring_ping_interval }}
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    file_sd_configs:
      - files:
          - pinghosts.yaml
    relabel_configs:
      - source_labels: [__address__]
        regex: '(.*);(.*)'  # first is the url, thus unique for instance
        target_label: instance
        replacement: $1
      - source_labels: [__address__]
        regex: '(.*);(.*)'  # second is humanname to use in charts
        target_label: humanname
        replacement: $2
      - source_labels: [instance]
        target_label: __param_target
      - target_label: __address__
        replacement: ping:9115  # The blackbox exporter's real hostname:port.

  - job_name: 'node'
    static_configs:
      - targets: {{ prometheus_node_exporter_targets | to_yaml }}

{% if pihole_enable %}
  - job_name: '{{ pihole_hostname }}'
    static_configs:
      - targets: ['pihole-exporter:9617']
{% endif %}

{% filter indent(width=2,first=True) %}
{{ prometheus_extra_scrape_configs }}
{% endfilter %}
